<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <title>管理员新增硬件</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link href="/css/bootstrap.min.css" rel="stylesheet">
    <!-- jQuery (Bootstrap 的 JavaScript 插件需要引入 jQuery) -->
    <script src="https://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script>
    <!-- 包括所有已编译的插件 -->
    <script src="js/bootstrap.min.js"></script>
</head>
<body style="padding-top: 90px">
    <script type="text/javascript">
        function addhardware(){//新增硬件信息
            if(document.getElementById("category").value == "CPU")
			{
				$.ajax({
				    type:'post',
				    url:"/updateCPU",
				    data:{
						"model":document.getElementById("name").value,
						"price":document.getElementById("price").value,
						"parameter":document.getElementById("parameter").value,
						"recommend":document.getElementById("recommend").value,
				    },
				    success:function(){
						alert("更新成功")
				    },
				    error:function () {
				        alert("failed")
				    }
				})
			}
			else if(document.getElementById("category").value == "显卡")
			{
				$.ajax({
				    type:'post',
				    url:"/updatedisplayCard",
				    data:{
						"model":document.getElementById("name").value,
						"price":document.getElementById("price").value,
						"parameter":document.getElementById("parameter").value,
						"recommend":document.getElementById("recommend").value,
				    },
				    success:function(){
						alert("更新成功")
				    },
				    error:function () {
				        alert("failed")
				    }
				})
			}
			else if(document.getElementById("category").value == "硬盘")
			{
				$.ajax({
				    type:'post',
				    url:"/updatehardCard",
				    data:{
						"model":document.getElementById("name").value,
						"price":document.getElementById("price").value,
						"parameter":document.getElementById("parameter").value,
						"recommend":document.getElementById("recommend").value,
				    },
				    success:function(){
						alert("更新成功")
				    },
				    error:function () {
				        alert("failed")
				    }
				})
			}
			else if(document.getElementById("category").value == "内存")
			{
				$.ajax({
				    type:'post',
				    url:"/updatememory",
				    data:{
						"model":document.getElementById("name").value,
						"price":document.getElementById("price").value,
						"parameter":document.getElementById("parameter").value,
						"recommend":document.getElementById("recommend").value,
				    },
				    success:function(){
						alert("更新成功")
				    },
				    error:function () {
				        alert("failed")
				    }
				})
			}
        }	
    </script>
    <nav class="navbar navbar-default navbar-fixed-top" role="navigation" style="background-color: #660066;">
        <div class="container-fluid" >
            <div class="navbar-header">
                <a class="navbar-brand" style="margin-left: 20px;color: rgb(255, 255, 255);" href="https://www.baidu.com/">主页</a>
            </div>
            <div>
                <ul class="nav navbar-nav">
                    <li class="dropdown">
                        <a href="#" class="dropdown-toggle" data-toggle="dropdown" style="font-size: 18px;margin-left: 40px;color: rgb(255, 255, 255);">
                            硬件信息<b class="caret"></b>
                        </a>
                        <ul class="dropdown-menu" style="background-color: #660066;">
                            <li><a href="#" style="font-size: 18px;color: rgb(255, 255, 255);">CPU</a></li>
                            <li><a href="#" style="font-size: 18px;color: rgb(255, 255, 255);">显卡</a></li>
                            <li><a href="#" style="font-size: 18px;color: rgb(255, 255, 255);">内存</a></li>
                            <li><a href="#" style="font-size: 18px;color: rgb(255, 255, 255);">硬盘</a></li>
                            <li><a href="#" style="font-size: 18px;color: rgb(255, 255, 255);">笔记本</a></li>
                        </ul>
                    </li>
                </ul>
            </div>
            <div class="navbar-header">
                <a class="navbar-brand" href="#" style="margin-left: 40px;color: rgb(255, 255, 255);">社区交流</a>
            </div>
            <div>
                <form class="navbar-form navbar-left" role="search" style="margin-left: 650px;">
                    <div class="form-group">
                        <input type="text" class="form-control" placeholder="输入查找的内容" style="width: 300px;">
                    </div>
                    <a href="https://www.baidu.com/">
                        <img src="search.png" width="35px" height="35px">
                    </a>
                </form>
            </div>
            <div>
                <a href="https://www.baidu.com/"><img src="头像.png" style="width: 37px;margin-top: 8px;"></a>
            </div>
        </div>
    </nav>

    <!-- 左部导航栏 -->
    <div class="col-md-2" style="margin-left:0px;margin-top:40px;">
        <div class="panel-group" id="accordion" >
            <div class="panel panel-default" >
                <div class="panel-heading" style="background-color: purple;">
                    <h5 class="panel-title">
                        <a data-toggle="collapse" data-parent="#accordion" href="#collapseOne">
                            <h5><span class="glyphicon glyphicon-th-list" style="color: rgb(231, 237, 238); font-size: 20px;"> 功能页面</span></h5>
                        </a>
                    </h5>
                </div>
                <div id="collapseOne" class="panel-collapse collapse in">
                    <div class="panel-body">
                        <div class="list-group">
                            <a class="list-group-item" style="color: rgb(117, 75, 187); font-size: 19px;" href="#">编辑文章</a>
                            <a class="list-group-item" style="color: rgb(117, 75, 187); font-size: 19px;" href="#">更新硬件</a>
                            <a class="list-group-item" style="color: rgb(117, 75, 187); font-size: 19px;" href="#">新增硬件</a>
                            <a class="list-group-item" style="color: rgb(117, 75, 187); font-size: 19px;" href="#">添加整机</a>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <div class="col-md-10">
        <div class="page-header">
            <h1 style="font-family: 微软雅黑;font-weight: bold;">新增硬件</h1>
        </div>
        <div class="row clearfix">
            <div class="col-md-12 column">
                <form class="form-horizontal" role="form">
                    <div class="form-group">
                        <label for="product category" class="col-sm-2 control-label">产品种类</label>
                        <div class="col-sm-5">
                            <input type="category" class="form-control" id="category" list="data1" placeholder="CPU"/>
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="product name" class="col-sm-2 control-label">产品名称</label>
                        <div class="col-sm-5">
                            <input type="name" class="form-control" id="name" />
                        </div>
                    </div>
					<div class="form-group">
					    <label for="price" class="col-sm-2 control-label">产品价格</label>
					    <div class="col-sm-5">
					        <input type="name" class="form-control" id="price" />
					    </div>
					</div>
                    <div class="form-group">
                        <label for="parameter" class="col-sm-2 control-label">产品参数</label>
                        <div class="col-sm-5">
                            <input type="name" class="form-control" id="parameter" />
                        </div>
                    </div>
					<div class="form-group">
					    <label for="product description" class="col-sm-2 control-label">产品评论</label>
					    <div class="col-sm-5">
					        <textarea type="description" class="form-control" id="recommend" style="width:500px;height: 200px" ></textarea>
					    </div>
					</div>
					
                </form>
            </div>
        </div>

        <div class="row-fluid">
            <div class="col-md-2">
            </div>
            <div class="col-md-1">
                <button onclick="addhardware" type="button" class="btn btn-default" style="width: 100px;height: 30px;font-size: medium">添加</button>
            </div>
            <div class="col-md-1">
                <button type="button" class="btn btn-default" style="width: 100px;height: 30px;font-size: medium">取消</button>
            </div>
        </div>
    </div>
    <datalist id="data1">
		<option>cpu</option>
        <option>显卡</option>
        <option>硬盘</option>
        <option>内存</option>
    </datalist>
</body>
</html>